package com.xinhe.web.controller;

import com.querydsl.core.QueryResults;
import com.xinhe.web.annotation.WebUsed;
import com.xinhe.web.common.Result;
import com.xinhe.web.response.WithdrawalsRecordSumView;
import com.xinhe.web.response.WithdrawalsRecordView;
import com.xinhe.web.response.WithdrawalsStatisticsView;
import com.xinhe.web.service.WithdrawalsRecordService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import java.math.BigDecimal;
import java.util.Date;
import java.util.Set;

@Api(value = "提现记录详情", tags = {"提现记录详情"})
@RestController
@RequestMapping(value = {"/withdrawalsRecord"}, produces = {"application/json;charset=UTF-8"})

public class WithdrawalsRecordController {

    @Autowired
    WithdrawalsRecordService withdrawalsRecordService;

    //会员提现管理面showType不传。昨日会员提现showType传0。今日会员提现showType传1。
    @WebUsed
    @ApiOperation("分页查询提现记录详情，即会员提现管理")
    @GetMapping({"/pageWithdrawalsRecord"})
    public QueryResults<WithdrawalsRecordView> pageWithdrawalsRecord(String queryWord, Date startTime, Date endTime,
                                                                     String status,int showType, int pageNum, int pageSize) {
        return withdrawalsRecordService.pageWithdrawalsRecord(queryWord,startTime,endTime,status,showType,pageNum,pageSize);
    }
    @WebUsed
    @ApiOperation("统计提现记录，即会员提现管理、会员用户提现")
    @GetMapping({"/findByWithdrawalsRecordSumAmount"})
    public Result<WithdrawalsRecordSumView> findByWithdrawalsRecordSumAmount() {
        return withdrawalsRecordService.findByWithdrawalsRecordSumAmount();
    }

    @WebUsed
    @ApiOperation(httpMethod = "GET", value = "提现统计，即昨日会员提现、今日会员提现统计")
    @RequestMapping({"/findByWithdrawalsStatistics"})
    public Result<WithdrawalsStatisticsView> findByWithdrawalsStatistics() {
        return withdrawalsRecordService.findByWithdrawalsStatistics();
    }

    @ApiOperation(httpMethod = "GET", value = "分页查询提现记录(用户)")
    @RequestMapping({"/pageUserWithdrawalsRecord"})
    QueryResults<WithdrawalsRecordView> pageUserWithdrawalsRecord(Long userId, int pageNum, int pageSize) {
        return withdrawalsRecordService.pageUserWithdrawalsRecord(userId,pageNum, pageSize);
    }

    @ApiOperation(httpMethod = "POST", value = "用户提现,金额不小于100")
    @RequestMapping({"/saveWithdrawalsRecord"})
    public Result saveWithdrawalsRecord(Long userId,BigDecimal money,String type,String remark,Long bankId,String mode) {//type默认给BALANCE
        return this.withdrawalsRecordService.saveWithdrawalsRecord(userId,money, type, remark, bankId, mode);
    }
    @ApiOperation(httpMethod = "POST", value = "提现审核")
    @RequestMapping({"/saveCheck"})
    Result saveCheck(Set<Long> ids, String checkResult, String remark) {
        return this.withdrawalsRecordService.saveCheck(ids, checkResult, remark);
    }
    @ApiOperation(httpMethod = "GET", value = "提现记录详情详情")
    @ApiImplicitParam(name = "withdrawalsRecordId", value = "标识", dataTypeClass = Long.class, required = true)
    @RequestMapping({"/detailWithdrawalsRecord"})
    public Result<WithdrawalsRecordView> detailWithdrawalsRecord(Long withdrawalsRecordId) {
        return this.withdrawalsRecordService.detailWithdrawalsRecord(withdrawalsRecordId);
    }
    @ApiOperation(httpMethod = "GET", value = "获取用户已提现金额")
    @RequestMapping({"/findByMemberWithdrawalsMoney"})
    public Result<BigDecimal> findByMemberWithdrawalsMoney(Long userId) {
        return this.withdrawalsRecordService.findByMemberWithdrawalsMoney(userId);
    }

    /*@ApiOperation(httpMethod = "POST", value = "导出记录")
    @RequestMapping({"/easyWithdrawalsRecordExcel"})
    public Result<String> easyWithdrawalsRecordExcel(WithdrawalsRecordQuery query) {
        return this.withdrawalsRecordService.easyWithdrawalsRecordExcel(query);
    }*/
}
